<?php
    namespace app\listen\controller;

    class Member extends \app\common\controller\Base {
        private $memberModel;
        function getMemberModel(): \app\listen\model\Member{
            if (empty($this->memberModel)) {
                $this->memberModel  = model('listen/Member');
            }
            return $this->memberModel;
        }
        public function edit() {
            $data= $this->getParams();
            $uid = $data['uid']??null;
            $sex = $data['sex']??null;
            $nickname = $data['nickname']??null;
            $headphoto = $data['headphoto']??null;
            $data = [];
            $res = false;
            if (isset($uid)) {
                $data['uid'] = $uid;
                if (isset($sex)) {
                    $data['sex'] = $sex;
                }
                if (isset($nickname)) {
                    $data['nickname'] = $nickname;
                }
                if (isset($headphoto)) {
                    $data['head_photo'] = $headphoto;
                }
                $res = $this->getMemberModel()->where('uid', $uid)->update($data);

            }
            if (false !== $res) {
                return api_return(10002, $res);
            } else {
                return api_return(-2017);
            }
        }

    }